package com.gec.it.util;

import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Md5Util {
    //md5加密类
    public static String digest(String pwd) {
        try {
            MessageDigest md5 = MessageDigest.getInstance("md5");//md5的加密工具
            byte[] digest = md5.digest(pwd.getBytes("Utf-8"));//md5吃进去的是byte[],返回的也是byte[]；
            String s = new BigInteger(1, digest).toString(16);
            return s;
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }
}
